﻿<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="news_column_edit.aspx.cs" Inherits="Ccit.OA.NewsCenter.news_column_edit" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>信息中心-栏目编辑</title>
    <script language="javascript" src="../script/jquery.js" type="text/javascript"></script>
    <script language="javascript" src="../script/StringClass_Ext.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jsonlib.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
      function initialAddNew(){
         $get("hdOper").value="0";
         $get("hdColumnId").value="";
         __doPostBack("lnbCallback","");
      }
      //保存
      function doSave(operType)
      {
         if(!checkForm())return;
         saveData(operType);
      }
      function saveData(operType)
      {
         var MsColumn={};
         MsColumn.columnId=$get("hdColumnId").value;          
         MsColumn.columnLevelCode=getDropDownSelValue("ddlColumn");
         
         if(MsColumn.columnId == MsColumn.columnLevelCode)
         {
             alert("上级栏目选择有误,请重新选择");
             return ;
         }
         MsColumn.columnName=$get("txtColumnName").value;
         MsColumn.infoType=$get("hdType").value;
         //单选按钮
         var rbtn = new RadioList("rbtnPubType");
         MsColumn.pubType= rbtn.checkedValue;
         rbtn = null;
         MsColumn.pubPurviewId=$get("hdPubId").value;
         MsColumn.pubPurviewType=$get("hdPubType").value;
         MsColumn.managePurview=$get("hdManageId").value;
         MsColumn.managePurviewType=$get("hdManageType").value;
         MsColumn.browsePurview=$get("hdBrowseId").value;
         MsColumn.browsePurviewType=$get("hdBrowseType").value;
         MsColumn.orderNo=$get("txtOrderNo").value;
         MsColumn.columnDesc=$get("txtColumnDesc").value;
         var jsonExpr=JSON.stringify(MsColumn,function(key,value){return value;});
         PageMethods.SaveColumn(jsonExpr,operType,ClientCallBack);
      }
      //获取选中文本框的值
      function getDropDownSelValue(ctrlId){
         var ddl=new DropDownList(ctrlId);
         var selValue=ddl.selectedValue;
         ddl=null;
         return selValue;
      }
      //验证
      function checkForm(){
         var columnName=$get("txtColumnName");
         if(jQuery.trim(columnName.value)==""){
           alert("栏目名称不能为空");
           columnName.focus();
           return false;
         }
         var orderNo = document.getElementById("txtOrderNo").value;
         if(orderNo != "" && isNaN(orderNo))
         {
            alert("显示顺序请输入数字");
            return false;
         }
         return true;
      }
      //返回
      function ClientCallBack(oResult){
         eval("var oResultObj="+oResult);
         alert(oResultObj.resMes);
         if(oResultObj.resType>0){
           var isAddNew = ($get("hdColumnId").value == "") ? "0" : "1"; 
           var columnName = $get("txtColumnName").value;
           switch(oResultObj.resOperType) {
                            case "1"://保存
                                $get("hdColumnId").value=oResultObj.resColumnId;
                                var Type = document.getElementById("hdType").value;
                                var vPageParam = "columnId=" + oResultObj.resColumnId+"&Type="+Type+"&oper=1&TABID="+document.getElementById("_hidTabId").value;
						        var encodeParam = base64encode(vPageParam);
                                parent.frames[1].location = "news_column_edit.aspx?"+encodeParam;
                             
                                break;
                            case "2": //保存并新增            
                                clear(oResultObj.resUpTypeId);
                                break;    
                        }
                        
                        var curColObj = {};
                        curColObj.columnId = oResultObj.resColumnId;
                        curColObj.columnName = columnName;
                        curColObj.hasChild = oResultObj.hasChildSign;
                        
                        var jsonExpr=JSON.stringify(curColObj,function(key,value){return value;});
                        parent.frames[0].document.getElementById("_hidNewColumnId").value=jsonExpr;
                        parent.frames[0].document.getElementById("_hidUpTypeId").value = oResultObj.resUpTypeId; //新的上级父节点            
                        parent.frames[0].document.getElementById("_hidOriUpTypeId").value = $get("_hidOriUpTypeId").value;
                        parent.frames[0].document.getElementById("_hidAddNewSign").value = isAddNew;  
                        parent.frames[0].document.getElementById("hdType").value = document.getElementById("hdType").value;
                        parent.frames[0].document.getElementById("_hidTabId").value = document.getElementById("_hidTabId").value;
                        parent.frames[0].document.all.btnTrigger.click();                          
                        $get("_hidOriUpTypeId").value = oResultObj.resUpTypeId;                        
                        
           }
      }
      function clear(selValue){  
         $get("hdColumnId").value="";        
         $get("ddlColumn").selectedValue=selValue;
         $get("txtColumnName").value="";
         $get("hdPubId").value="";
         $get("hdPubType").value="";
         $get("hdManageId").value="";
         $get("hdManageType").value="";
         $get("hdBrowseId").value="";
         $get("hdBrowseType").value="";
         $get("txtOrderNo").value="";
         $get("txtColumnDesc").value="";
         $get("txtPubPurview").value="";
         $get("txtManagePurview").value="";
         $get("txtBrowsePurview").value="";
      }
      //通用范围选择页面
      function SelRange(ctrType,ctrId,ctrName){
         OpenRangeSelect(ctrType,ctrId,ctrName,"0");
      }
    </script>
</head>
<body>
    <Ccit:ActionForm id="form1" runat="server">
    <input type="hidden" id="_hidTabId" runat="server" />
    <input type="hidden" id="_hidWhereClause" runat="server" />
    <!--修改主键-->
    <input type="hidden" value="" id="hdColumnId" runat="server" />
    <!--操作标志-->
    <input type="hidden" value="" id="hdOper" runat="server" />
    <!--信息类型-->
    <input type="hidden" value="" id="hdType" runat="server" />
    <!--点击父节点自带的id-->
    <input type="hidden" id="_hidOriUpTypeId" runat="server" />
    <asp:LinkButton ID="lnbCallback" runat="server" Visible="false" onclick="lnbCallback_Click"></asp:LinkButton>
    <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server"></asp:ScriptManager>
    <table class="tableborder" cellpadding="0" cellspacing="0" width="98%" align="center" runat="server" id="tab1">
        <tr>
            <td width="10%" class="pformleft" align="right"><nobr>上级栏目</nobr></td>
            <td width="90%" colspan="3" class="pformright">
               <asp:DropDownList ID="ddlColumn" CssClass="select" runat="server" Width="99.8%"></asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td width="10%" class="pformleft" align="right"><nobr><font color="red">*</font>栏目名称</nobr></td>
            <td width="90%" colspan="3" class="pformright">
               <asp:TextBox ID="txtColumnName" CssClass="input" Width="99.8%" runat="server"></asp:TextBox>                
            </td>
        </tr>
        <tr>
            <td width="10%" class="pformleft" align="right"><nobr>发布类型</nobr></td>
            <td width="90%" colspan="3" class="pformright">
               <asp:RadioButtonList ID="rbtnPubType" runat="server" RepeatDirection="Horizontal">
                 <asp:ListItem Value="0">直接发布</asp:ListItem>
                 <asp:ListItem Value="1">审核发布</asp:ListItem>
               </asp:RadioButtonList>                
            </td>
        </tr>
        <tr>
            <td width="10%" class="pformleft" align="right"><nobr>发布权限</nobr></td>
            <td width="90%" colspan="3" class="pformright">
                <input type="hidden" id="hdPubType" runat="server" />
                <input type="hidden" id="hdPubId" runat="server" />
                <asp:TextBox ID="txtPubPurview"  ReadOnly CssClass="inputReadonly" Width="94%" runat="server"></asp:TextBox>                
                <img src="../images/edit_logo/SEARCH.GIF" width="25" onclick="SelRange('hdPubType','hdPubId','txtPubPurview')" height="25" border="0" />  
            </td>
        </tr>
        <tr>
            <td width="10%" class="pformleft" align="right"><nobr>管理权限</nobr></td>
            <td width="90%" colspan="3" class="pformright">
                <input type="hidden" id="hdManageType" runat="server" />
                <input type="hidden" id="hdManageId" runat="server" />
                <asp:TextBox ID="txtManagePurview"  ReadOnly CssClass="inputReadonly"  Width="94%" runat="server"></asp:TextBox>                
                <img src="../images/edit_logo/SEARCH.GIF" width="25" onclick="SelRange('hdManageType','hdManageId','txtManagePurview')" height="25" border="0" />    
            </td>
        </tr>
        <tr>
            <td width="10%" class="pformleft" align="right"><nobr>浏览权限</nobr></td>
            <td width="90%" colspan="3" class="pformright">
                <input type="hidden" id="hdBrowseType" runat="server" />
                <input type="hidden" id="hdBrowseId" runat="server" />
                <asp:TextBox ID="txtBrowsePurview"  ReadOnly CssClass="inputReadonly" Width="94%" runat="server"></asp:TextBox>                
                <img src="../images/edit_logo/SEARCH.GIF" width="25"onclick="SelRange('hdBrowseType','hdBrowseId','txtBrowsePurview')"  height="25" border="0" />
            </td>
        </tr>
        <tr>
            <td width="10%" class="pformleft" align="right"><nobr>显示顺序</nobr></td>
            <td width="90%" colspan="3" class="pformright">
                <asp:TextBox ID="txtOrderNo" CssClass="input" Width="99.8%" runat="server"></asp:TextBox>                
            </td>
        </tr>
        <tr>
            <td width="10%" class="pformleft" align="right"><nobr>栏目说明</nobr></td>
            <td width="90%" colspan="3" class="pformright">
                <%--<textarea id="txtColumnDesc" class="inputarea" runat="server" rows="5" style="width:99.8%;" ></textarea> --%>
                <textarea id="txtColumnDesc" runat="server" class="inputarea" rows="5" style="width:99.8%"></textarea>
               <%-- <asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="5" CssClass="textinput" Width="99.8%" runat="server"></asp:TextBox>                --%>
            </td>            
        </tr>
        <tr class="pformstrip">
            <td colspan="4" align="center">
            <input type="button" id="btnSave" onclick="doSave('1')" value="保存" class="button"  runat="server" />
            &nbsp;
                <input type="button" id="btnSaveAdd" onclick="doSave('2')" value="保存并新增" class="button" runat="server" />
            </td>
         </tr>
       </table>
    </Ccit:ActionForm>    
</body>
</html>
